﻿#include <Sys\RenderUnit\SysRenderDatagram\SOLIDRD.HPP>
#include <Render\Render_Win32\Render_Win32_D3D\RENDER_WIN32_D3D9.HPP>
#include <Sys\RenderUnit\SYSDDCLASSID.HPP>

using namespace CxxlMan;
using namespace Cxxl3D;

class CSolidDD_D3D9:public IDatagramDisposal_D3d9
{
  virtual bool cxxlFASTCALL Exec(const Smart_Ptr<IRenderDatagramDisposalCenterD3d> &IRenderDatagramDisposalCenterD3d_Arg,
    const Smart_Ptr<IRenderDatagram> &IRenderDatagram_Arg, LPDIRECT3DDEVICE9 pDEVICE9)
  {
    Smart_Ptr<ISolidRD> ISolidRD_Ptr = (ISolidRD*)GetDefaultInterface(IRenderDatagram_Arg);

    tagISolidRD_Cfg Cfg = ISolidRD_Ptr->GetCfg();

    pDEVICE9->SetRenderState(D3DRS_LIGHTING, Cfg.Light == 1);


    DWORD CullMode;
    switch(Cfg.CullMode)
    {
    case 0:
      CullMode = D3DCULL_NONE;
      break;
    case 1:
      CullMode = D3DCULL_CW;
      break;
    case 2:
      CullMode = D3DCULL_CCW;
    }

    pDEVICE9->SetRenderState(D3DRS_CULLMODE, CullMode);

   // Smart_Ptr<IBasicPrimitiveRD> IBasicPrimitiveRD_Ptr = ISolidRD_Ptr->GetIBasicPrimitiveRD();

   // return IRenderDatagramDisposalCenterD3d_Arg->Exec((IBasicPrimitiveRD *)IBasicPrimitiveRD_Ptr, pDEVICE9);      
    return true;
  }

public:
  CSolidDD_D3D9()
   :cxxlObject(Spirit_Easy) 
  {
  }

  // Destructor
  virtual ~CSolidDD_D3D9()
  {
  }

};

cxxlObject *cxxlFASTCALL New_CSolidDD_D3D9()
{
  return new CSolidDD_D3D9;
}